﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using BlawkayMobileLibrary;

namespace Bounce
{
    public class AimLine
    {
        public AimLine(Texture2D oTexture)
        {
            Texture = oTexture;
            Position_A = Vector2.Zero;
            Position_B = Vector2.Zero;
            Origin = new Vector2(Texture.Width * 0.5f, Texture.Height * 0.5f);
            Scale = new Vector2(0.1f, 1.0f);
        }

        public void Draw(SpriteBatch oSpriteBatch)
        {
            float Rotation = LineSegment.Rotation(Position_A, Position_B);
            float Length = LineSegment.Length(Position_A, Position_B);
            Vector2 MidPoint = LineSegment.MidPoint(Position_A, Position_B);

            Scale.Y = Length / Texture.Height;

            oSpriteBatch.Draw(
                Texture,
                MidPoint,
                null,
                Color.Blue,
                Rotation,
                Origin,
                Scale,
                SpriteEffects.None,
                0.9f);
        }

        public Vector2 Position_A;
        public Vector2 Position_B;

        protected Vector2 Origin;
        protected Vector2 Scale;
        protected Texture2D Texture;

    }
}
